n = int(input())

array = [[0]*(i+1) for i in range(n)]

for i in range(n):
    cnt = [int(i) for i in input().split()]
    array[i][:] = cnt[:]

for i in range(1,n):
    for j in range(i+1):
        if j==0 :
            array[i][j] += array[i-1][j]
        elif j==i:
            array[i][j] += array[i-1][j-1]
        else:
            array[i][j] += max(array[i-1][j-1],array[i-1][j])

if n%2==1:
    print("{}".format(array[n-1][(n-1)//2]),end="")
else:
    print("{}".format(max(array[n-1][(n-1)//2 -1],array[n-1][n//2])),end="")
